package com.example.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.pojo.careerTalk;
import org.apache.ibatis.annotations.*;

import java.util.Date;

@Mapper
public interface MeetingMapper {
    //分页展示宣讲会信息
    @Select("select * from careertalk")
    IPage<careerTalk> findAllTalkList(Page<careerTalk> careerTalkPage);

    //根据类型分类
    @Select("select * from careertalk where Type =#{type}")
    IPage<careerTalk> sortByType(String type,Page<careerTalk> careerTalkPage);

    //根据关键字查询
    @Select("select * from careertalk where Name like concat('%', #{key}, '%')")
    IPage<careerTalk> findByKey(String key, Page<careerTalk> careerTalkPage);

    //叠加查询
    @Select("select * from (select * from careertalk where Name like concat('%', #{key}, '%')) as cTable where Type =#{type} ")
    IPage<careerTalk> multiFind(String type, String key, Page<careerTalk> careerTalkPage);

    //删除宣讲会信息
    @Delete("delete from careertalk where Name=#{name}")
    void deleteMeeting(String name);

    //编辑宣讲会信息
    @Update("update careertalk set Type=#{Type},startDate=#{startDate},endDate=#{endDate},Address=#{Address} where Name=#{Name}")
    void editMeeting(careerTalk c);

    //新增宣讲会信息
    @Insert("insert into careertalk(Name,Type,startDate,endDate,Address)"+"values(#{Name},#{Type},#{startDate},#{endDate},#{Address})")
    void addMeeting(careerTalk c);

    //查找宣讲会信息
    @Select("select * from careertalk where Name=#{name}")
    careerTalk findByDate(String name);
}
